class TransactionFilter:
    '''used with threaded session management.
    '''
    order = 30

    def __init__(self, sessionmaker):
        self.sessionmaker = sessionmaker

    def __call__(self, view, next):
        """Rolls back the database and leaves transaction management"""
        try:
            next()
        except Exception:
            self.sessionmaker.rollback()
            raise
        else:
            self.sessionmaker.commit()
        finally:
            #self.sessionmaker.remove()
            pass
